package com.cw.jeeyt.service.converter.system;

import java.util.List;
import java.util.ArrayList;

import com.google.common.collect.Iterators;
import com.google.common.collect.Lists;
import com.cw.jeeyt.service.bo.system.SysScaffoldModuleBo;
import com.cw.jeeyt.dao.model.system.SysScaffoldModuleDo;
import com.cw.lang.common.utils.CollectionUtil;

/**
 * 脚手架模块转换类
 *
 * @author chenw
 * @date 2020-05-26 15:00:07
 */
public class SysScaffoldModuleConverter {

    /**
     * do转bo
     *
     * @param model
     * @return
     */
    public static SysScaffoldModuleBo do2Bo(SysScaffoldModuleDo model) {
        SysScaffoldModuleBo bo = new SysScaffoldModuleBo();
        if (model == null) {
            return bo;
        }
        bo.setId(model.getId());
        bo.setModuleCode(model.getModuleCode());
        bo.setModuleName(model.getModuleName());
        return bo;
    }

    /**
     * bo转do
     *
     * @param bo
     * @return
     */
    public static SysScaffoldModuleDo bo2Do(SysScaffoldModuleBo bo) {
        SysScaffoldModuleDo model = new SysScaffoldModuleDo();
        if (bo == null) {
            return model;
        }
        model.setId(bo.getId());
        model.setModuleCode(bo.getModuleCode());
        model.setModuleName(bo.getModuleName());
        return model;
    }

    /**
     * doList转boList
     *
     * @param doList
     * @return
     */
    public static List<SysScaffoldModuleBo> doList2BoList(List<SysScaffoldModuleDo> doList) {
        if (CollectionUtil.isEmpty(doList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(doList.iterator(), SysScaffoldModuleConverter::do2Bo));
    }

    /**
     * boList转doList
     *
     * @param boList
     * @return
     */
    public static List<SysScaffoldModuleDo> boList2DoList(List<SysScaffoldModuleBo> boList) {
        if (CollectionUtil.isEmpty(boList)) {
            return new ArrayList<>();
        }
        return Lists.newArrayList(Iterators.transform(boList.iterator(), SysScaffoldModuleConverter::bo2Do));
    }
}
